<!DOCTYPE html>
<html>
<head>
	<meta charset="UTF-8">
	<meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="stylesheet" href="../../css/utils/bootstrap.min.css" />
    <link rel="stylesheet" href="../../css/utils/common.css" />
    <link rel="stylesheet" href="../../css/utils/toastr.min.css" />
	<title></title>
	<style>
		/*-------------修改密码------------*/
		.col-top {
			margin-top: 100px;
		}
		.col-top .form-group {
			margin-bottom: 25px;
		}
		.text-red {
		    color: #ee4747;
		}
		.no-padder {
		    padding: 0 !important;
		}
		.btn-primary:focus, .btn-primary:hover {
			color: #fff;
			background-color: #2aeee2;
			border-color: #2aeee2;
		}
		.btn-primary {
		    color: #fff;
		    background-color: #11B5AB;
		    border-color: #11B5AB;
		}
		.cancle {
			color: #7B7B7B;
			background-color: #F3F3F3;
		    border-color: #F3F3F3;
		}
		/*-------------修改密码------------*/
	</style>
</head>
<body>
	<div class="content">
		<div class="col-md-offset-3 col-md-6 col-top">
			<form class="form-horizontal" id="pwdForm">
				<div class="form-group">
					<label for="recipient-name" class="control-label col-md-4"><span class="text-red">*</span> 原密码：</label>
					<div class="col-md-6 no-padder">
						<input type="password" class="form-control" placeholder="请输入原始密码" id="originalPwd" name="originalPwd">
					</div>
				</div>
				<div class="form-group">
					<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> 新密码：</label>
					<div class="col-md-6 no-padder">
						<input type="password" class="form-control" id="new_password" name="new_password" placeholder="请输入6-16位字符的新密码" />
					</div>
				</div>
				<div class="form-group">
					<label for="message-text" class="control-label col-md-4"><span class="text-red">*</span> 确认密码：</label>
					<div class="col-md-6 no-padder">
						<input type="password" class="form-control" id="confirm_password" name="confirm_password" placeholder="请确认您的新密码" />
					</div>
				</div>
				<div class="form-group">
					<div class="col-md-offset-4 col-md-6 no-padder">
						<button type="submit" id="save" class="btn btn-primary btn-width" >保存</button>
					</div>
				</div>
			</form>
		</div>
	</div>
	
	<script type="text/javascript" src="../../js/utils/jquery-1.12.4.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/bootstrap.min.js" ></script>
	<script type="text/javascript" src="../../js/utils/jquery.cookie.js" ></script>
	<script type="text/javascript" src="../../js/utils/jquery.validate.min.js?version=1" ></script>
	<script type="text/javascript" src="../../js/utils/boot.js" ></script>
	<script type="text/javascript" src="../../js/utils/toastr.min.js" ></script>
	<script>
		var userID = $.cookie("userID");
		var companyID = $.cookie("companyID");
		var companyName = $.cookie("companyName");
		$(function() {
			toastr.options = {
                "closeButton": true,
                "timeOut": 2000,
                "positionClass": "toast-center"
           	};
		})
		$("#pwdForm").validate({
	       	rules:{
	       		originalPwd: {
	       			minlength: 6,
	       			required:true,
	       		},
				new_password:{
					required:true,
				},
				confirm_password:{
					required:true,
					equalTo:"#new_password"    //新密码的id选择器
				}                    
	       	},
	       	messages:{
	       		originalPwd: {
	       			required: "请输入原密码",
	       		},
	          	new_password:{
	               	required: "请输入新密码",
	           	},
	          	confirm_password:{
					required: "请确认新密码",
					equalTo:"两次密码输入不一致"
	           	}                                    
	       },
	       submitHandler: function() {
				var data = {
					userID:userID,
					password:$("#originalPwd").val(),
					newPassword:$("#confirm_password").val()
				}
				base.postData(base.url.updatePassword, data, function(data) {
					if (data.success) {
						$("#originalPwd").val("");
						$("#new_password").val("");
						$("#confirm_password").val("");
						toastr.success(data.msg);
					} else {
						toastr.error(data.msg);
					}
				});
		    }
		})
	</script>
</body>
</html>
